<{include file="common/header.tpl"}>
<div class="row">
    <div class="col-md-2"></div>
    <div class="col-md-6">
        <select name="key" id="key" class="form-control">
            <{foreach item=item key=index from=$keys}>
            <option value="<{$item}>"><{$item}></option>
            <{/foreach}>
        </select>
    </div>
    <div class="col-md-2">
        <input type="button" name="submit" value="查询" onclick="get('key');" class="btn">&nbsp;&nbsp;
        <input type="button" name="del" value="删除" onclick="del('key');" class="btn">
    </div>
    <div class="col-md-2"></div>
</div>

<div class="row">
    <div class="col-md-2"></div>
    <div class="col-md-6">
        <input type="text" class="form-control" name="mc_key">
    </div>
    <div class="col-md-2">
        <input type="button" name="submit" value="查询" onclick="get('mc_key');" class="btn">&nbsp;&nbsp;
        <input type="button" name="del" value="删除" onclick="del('mc_key');" class="btn">
    </div>
    <div class="col-md-2"></div>
</div>
<div class="row clearfix top-span-block"></div>
<div class="row">
    <div class="col-md-2"></div>
    <div class="col-md-8">
        <span class="data"></span>
    </div>
    <div class="col-md-2"></div>
</div>
<{include file="common/footer.tpl"}>
<script>
    function get(keyName) {
        var key = $("select[name="+keyName+"]").val();
        if (key === undefined) {
            key = $("input[name="+keyName+"]").val();
        }
        $.ajax({
            url: '/cache/get',
            data: {
                key: key
            },
            success: function (res) {
                $("span.data").html(JSON.stringify(res.result));
            }
        });
    }
    function del(keyName) {
        var key = $("select[name="+ keyName +"]").val();
        if (key === undefined) {
            key = $("input[name="+keyName+"]").val();
        }
        $.ajax({
            url: '/cache/del',
            data: {
                key: key
            },
            success: function (res) {
                $("span.data").html(res.result);
            }
        });
    }
</script>
